package com.mc.search;

/**
 * @Description: 顺序查找
 * @Author: MoChen
 */
public class SeqSearch {
    static int[] arrs = {10, 20, 30, 40, 50};

    public static void main(String[] args) {
        System.out.println(seq_search(arrs, 10));
    }

    /**
     * 此处思路与教材思路不一致，教材中arrs[0]用于存储哨兵，可避免for循环中的下标越界
     */
    static boolean seq_search(int[] arrs, int num){
        for (int i = 0; i < arrs.length; i++){
            if(num == arrs[i]){
                return true;
            }
        }
        return false;
    }
}
